#include "widget.h"
#include "ui_widget.h"
#include<QPainter>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
        QPainter painter(this);
        painter.drawPixmap(20,100,QPixmap(":/kelee.png"));
        connect(ui->pushButton,&QPushButton::clicked,[=](){
            posx+=20;
           update();
        });
}
//void Widget::paintEvent(QPaintEvent *){
//    QPainter painter(this);
//    QPen pen(QColor(255,0,0));
//    QBrush brush(Qt::cyan);
//    brush.setStyle(Qt::BrushStyle::VerPattern);
//    pen.setWidth(20);
//    pen.setStyle(Qt::DashLine);
//    painter.setPen(pen);
//    painter.setBrush(brush);
//    painter.drawLine(QPoint(0,0),QPoint(100,100));
//    painter.drawEllipse(QPoint(100,100),100,50);
//    painter.drawRect(QRect(QPoint(200,200),QPoint(400,400)));
//    painter.drawText(QRect(300,300,100,100),"hao");
//} ;
void Widget::paintEvent(QPaintEvent *){
    QPainter painter(this);
    QPainter painter2(this);
    static int posx2=0;
    if(posx>this->width()){
        posx=0;
    }
    if(posx2>this->width()){
        posx2=0;
    }
//    painter.drawEllipse(QPoint(500,500),100,100);
//    painter.setRenderHint(QPainter::Antialiasing);
//    painter.drawEllipse(QPoint(400,400),100,100);
//    painter.translate(100,0);
//    painter.save();
//    painter.drawEllipse(QPoint(400,400),100,100);
//    painter.translate(100,0);
//    painter.restore();
//    painter.drawEllipse(QPoint(400,400),100,100);
    painter.drawPixmap(posx,100,QPixmap(":/kelee.png"));
    painter.drawPixmap(200+posx2++,200,QPixmap(":/kelee.png"));
    update();
}

Widget::~Widget()
{
    delete ui;
}

